package com.hudongwx.godoffood.activity.Shopping_Activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hudongwx.godoffood.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_invoice)
public class InvoiceActivity extends AppCompatActivity {
    @ViewInject(R.id.invoice_bu_1)
    Button button_1;
    @ViewInject(R.id.invoice_bu_2)
    Button button_2;
    @ViewInject(R.id.invoice_bu_3)
    Button button_3;
    @ViewInject(R.id.invoice_ll)
    LinearLayout linearLayout;
    @ViewInject(R.id.invoice_ed)
    EditText ed;
    @ViewInject(R.id.invoice_fra)
    FrameLayout fra;
    @ViewInject(R.id.invoice_ll_2)
    LinearLayout ll_2;
    @ViewInject(R.id.invoice_eat)
    TextView eat;
    @ViewInject(R.id.invoice_ryp)
    TextView ryp;
    @ViewInject(R.id.invoice_mx)
    TextView mx;
    String text;
    String text1;
     Editable text2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
    }


    @Event(value = {R.id.invoice_bu_1, R.id.invoice_bu_2, R.id.invoice_bu_3, R.id.invoice_bu})
    private void bu(View view) {
        switch (view.getId()) {
            case R.id.invoice_bu_1:
                text1 = (String) button_1.getText();

                text = "";
                ed.setText("");
                text2=ed.getText();

                break;
            case R.id.invoice_bu_2:
                linearLayout.setVisibility(View.VISIBLE);
                fra.setVisibility(View.VISIBLE);
                text2=ed.getText();
                text1="";
                Log.i("获取", "bu: "+text1);
                break;
            case R.id.invoice_bu_3:
                linearLayout.setVisibility(View.VISIBLE);
                fra.setVisibility(View.GONE);
                text1 = (String) button_3.getText();
                ed.setText("");
                text2=ed.getText();
                break;
            case R.id.invoice_bu:

                Intent intent = new Intent(InvoiceActivity.this, ConfirmActivity.class);
                intent.putExtra("xinxi", text1);
                intent.putExtra("on",text+text2+"");
                setResult(3,intent);
                finish();
                break;

        }
    }
    @Event(R.id.invoice_back)
private void back(View view){
        finish();
    }
    @Event(value = {R.id.invoice_eat, R.id.invoice_ryp, R.id.invoice_mx})
    private void onclik(View view) {
        if (!view.isSelected()) {
            for (int i = 0; i < ll_2.getChildCount(); i++) {
                ll_2.getChildAt(i).setSelected(false);
            }
            view.setSelected(true);
        } else {
            view.setSelected(false);
        }
        TextView tv = (TextView) view;
        tv.getText();
        switch (view.getId()) {
            case R.id.invoice_eat:
                text = (String) eat.getText();
                break;
            case R.id.invoice_ryp:
                text = (String) ryp.getText();
                break;
            case R.id.invoice_mx:
                text = (String) mx.getText();
                break;
        }

    }
}
